#include <bits/stdc++.h>
using namespace std;
vector<int>a[100005];
int m,n;
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;++i){
		int x,y;cin>>x>>y;
		a[x].push_back(y);
	}
	for(int i=1;i<=n;++i)sort(a[i].begin(),a[i].end());
	for(int i=1;i<=n;++i){
		unsigned t=a[i].size();cout<<t;
		for(unsigned j=0;j<t;++j)cout<<' '<<a[i].at(j);
		cout<<endl;
	}
	return 0;
}
